import 'package:flutter/material.dart';
import '../utils/storage.dart';

class GlobalData with ChangeNotifier {
  String token = '';
  int type;
  int school_id;

  setToken(token1) {
    token = token1;
    notifyListeners();
  }

  setType(type1) {
    type = type1;
    notifyListeners();
  }

  setSchoolId(schoolId) {
    school_id = schoolId;
    notifyListeners();
  }

  getToken() {
    return token;
  }

  initUser() async {
    var getToken = await show('getString', 'token');
    var getType = await show('getInt', 'info_type');
    var schoolId = await show('getInt', 'school_id');
    if (getToken != null && getType != null) {
      token = getToken;
      type = getType;
      school_id = schoolId;
      notifyListeners();
      return true;
    }
    return false;
  }
}
